package com.wqr.mobile.android.ui.task;

import android.os.AsyncTask;

/**
 * 
 * @author wenqiurong
 * 
 */
public class DownLoaderTask extends AsyncTask<DownloadParames, Integer, DownloadTaskResult> {
	private ImageTaskCallBack mCallBack;

	public DownLoaderTask(ImageTaskCallBack mCallBack) {
		this.mCallBack = mCallBack;
	}

	@Override
	protected void onPostExecute(DownloadTaskResult result) {
		mCallBack.onTaskFinish(result);
		super.onPostExecute(result);
	}

	@Override
	protected DownloadTaskResult doInBackground(DownloadParames... params) {
		return mCallBack.onDownloadImage(params[0]);
	}

	@Override
	protected void onProgressUpdate(Integer... values) {
		super.onProgressUpdate(values);
	}

	/**
	 * 
	 * @author wenqiurong
	 * 
	 */
	public interface ImageTaskCallBack {

		/**
		 * on Task Finish
		 * 
		 * @param result
		 */
		public void onTaskFinish(DownloadTaskResult result);

		/**
		 * on Download Image
		 * 
		 * @param params
		 * @return
		 */
		public DownloadTaskResult onDownloadImage(DownloadParames params);
	}

}
